/**
 * 
 */
package com.thon.service.user.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;





import com.thon.dao.system.DicDataDao;
import com.thon.dao.user.SpecialistDao;
import com.thon.dao.util.Page;
import com.thon.entity.system.DicData;
import com.thon.entity.user.Specialist;
import com.thon.service.user.SpecialistService;

/**
 * @author manpiaoyi
 * @mail manpiaoyi@126.com
 * @date 2014-10-29
 * @description
 */
@Service
@Transactional
public class SpecialistServiceImpl implements SpecialistService {
	
	@Autowired
	private SpecialistDao specialistDao;	

	@Autowired
	private DicDataDao dicDataDao;

	@Override
	public Specialist read(Integer id) {		
		
	    return specialistDao.get(id);
	}

	@Override
	public String create(Specialist specialist) {
		String msg = "success";		
		specialistDao.save(specialist);
		return msg;
	}

	@Override
	public String delete(Integer id) {
		String msg = "success";		
		specialistDao.delete(id);
		return msg;
	}

	@Override
	public String update(Specialist specialist) {
		String msg = "success";		
		if(specialist.getSfzjmc()==null)
			return "sfzjmc is null";
		specialist.setSfzjmc(dicDataDao.get(specialist.getSfzjmc().getId()));
		specialistDao.update(specialist);
		return msg;
	}

	@Override
	public List<Specialist> readList() {
	
			return specialistDao.readList();
	
	}

	@Override
	public Page<Specialist> readListPage(Integer pageNo, Integer pageSize) {
		Page<Specialist> page = new Page<Specialist>();
		page.setPageNo(pageNo);
		page.setPageSize(pageSize);
		page.desc("id");
		return specialistDao.readListPage(page);
	}
	
}
